0 關注者

類別 yii\web\TooManyRequestsHttpException

繼承yii\web\TooManyRequestsHttpException » yii\web\HttpException » yii\base\UserException » yii\base\Exception » Exception
版本可用性2.0
原始碼 https://github.com/yiisoft/yii2/blob/master/framework/web/TooManyRequestsHttpException.php

TooManyRequestsHttpException 代表 "請求過多" HTTP 例外,狀態碼為 429。

使用此例外來指示客戶端在給定時間段內發出了過多請求。例如,當對 API 使用者進行「節流」時,您會拋出此例外。

另請參閱 https://tools.ietf.org/html/rfc6585#section-4

公開屬性

隱藏繼承的屬性

屬性 類型 描述 定義於
$statusCode integer HTTP 狀態碼,例如 403、404、500 等。 yii\web\HttpException

方法詳情

隱藏繼承的方法

__construct() 公開方法

建構子。

public void __construct ( $message null, $code 0, $previous null )
$message string|null

錯誤訊息

$code integer

錯誤代碼

$previous Throwable|null

用於例外鏈結的前一個例外。

                public function __construct($message = null, $code = 0, $previous = null)
{
    parent::__construct(429, $message, $code, $previous);
}

            
getName() 公開方法
public string getName ( )
回傳 string

這個例外的使用者友善名稱

                public function getName()
{
    if (isset(Response::$httpStatuses[$this->statusCode])) {
        return Response::$httpStatuses[$this->statusCode];
    }
    return 'Error';
}